#include"declare.h"

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	char choice[5];
	School *first_school = Initlist_school();
	Sport *first_sport = Initlist_sport(); 
	
	//每次开始运行的时候进行文件的读取
	Read_school(first_school);
	Read_sport(first_sport);
	
	while(1)
	{
		//调用主菜单函数
		Main_menu(); 
		//根据用户输入的选择，进行相应的操作 
		printf("请输入您的选择:\n");
		scanf("%s",&choice);
		system("cls");
		if(strcmp(choice, "1") == 0)	//录入基本信息
		{
			Input(first_school, first_sport);
		}
		else if(strcmp(choice, "2") == 0)	//查询 
		{
			Check(first_school, first_sport);
		}
		else if(strcmp(choice, "3") == 0)	//修改 
		{
			Review(first_school, first_sport);
		} 
		else if(strcmp(choice, "4") == 0)	//退出
		{
			//退出程序时保存信息到文件里
			Save_school(first_school);
			Save_sport(first_sport);
			Free(first_school, first_sport);
			printf("欢迎下次使用！"); 
			return 1;
		}
		else	//非法输入
		{
			printf("输入有误，请重新输入。\n");
			system("pause");
			system("cls");
		}
	}
	return 0;
}

